
<#include "/base/common/head.html"/>
    
    <table id="dg"></table>
    <div id="tb" style="padding:2px 5px;">
        <div class="wrap_search">
				            
			            	<span class="search_item">
				            	<span class="item_text">用车人：</span>
				            	<span class="item_obj">
				            		<input class="easyui-textbox" type="text" name="user" id="user" value="" addClear data-options=""></input>
				            	</span>    
				            </span>
				          
				            
		        			<span class="search_item search_between">
				                <span class="item_text">出发时间：</span>
				                <span class="item_obj">
				                    <input class="easyui-datebox" name="beginTime_start" id="beginTime_start" value="" data-options="editable:false,width:'110px'" addClear/> ~ <input class="easyui-datebox" name="beginTime_end" id="beginTime_end" value="" addClear data-options="editable:false,width:'110px'"/>
				                </span>
				            </span>
				            
				            
			            	<span class="search_item">
				            	<span class="item_text">申请人：</span>
				            	<span class="item_obj">
				            		<input class="easyui-textbox" type="text" name="applyUserName" id="applyUserName" value="" addClear data-options=""></input>
				            	</span>    
				            </span>
		        		
        </div>
        <div style="text-align: left; margin:6px;">
        	<!--  
            -->
            <a href="javascript:void(0)" class="easyui-linkbutton detailBtn" iconCls="glyphicon-map-marker" plain="true" onclick="detail()">详情</a>
            <div id="searchBtnWrap" style="float:right; padding-right:40px;">
                <a href="javascript:void(0)" class="easyui-linkbutton color1" iconCls="glyphicon-search" onclick="zcurdSearch()">搜索</a>
                <a href="javascript:void(0)" class="easyui-linkbutton color2" iconCls="glyphicon-repeat" onclick="flushPage()">重置</a>
            </div>
            
        </div>
    </div>
    
<style type="text/css">
	.subtotal { font-weight: bold; }/*合计单元格样式*/
</style>

<script type="text/javascript">

//数据表格初始化参数
var dgOptions = {
        rownumbers:true,
    	fit:true,
    	border:false,
    	url:'listData',
    	method:'post',
    	toolbar:'#tb',
    	pageSize: 20,
    	pagination:true,
    	//fitColumns:true,
    	striped:true,
    	multiSort:false, //是否允许多列排序
		sortName:'beginTime', //初始排序字段
		sortOrder:'desc', //初始排序方式
    	singleSelect: false,
		ctrlSelect : true,
		showFooter : true,
        queryParams: zcurdGetParam(),
        onDblClickRow:function(index, row){viewData(row.id);},
        columns: [[
		         {field:'id', checkbox:true}
	           	 ,{field:'beginTime', title: '出发时间', width:110, align:'center',sortable:true}
	           	 ,{field:'user', title: '用车人', width:100, align:'center'}
	           	 ,{field:'destination', title: '目的地', width:100, align:'center'}
	           	 ,{field:'remark', title: '备注', width:100, align:'center'}
	           	 ,{field:'applyUserName', title: '申请人', width:60, align:'center',sortable:true}
	           	 ,{field:'approver', title: '审批人', width:80, align:'center'}
	           	 ,{field:'state', title: '状态', width:60, align:'center', formatter:formatState}
	           	 ,{field:'car', title: '车辆', width:80, align:'center', formatter:formatType}
	           	 ,{field:'endTime', title: '归队时间', width:110, align:'center',sortable:true}
	           	 ,{field:'useTime', title: '总时长', width:60, align:'center',sortable:true}
	           	 ,{field:'waitTime', title: '等待时长', width:70, align:'center',sortable:true}
	           	 ,{field:'beginNum', title: '出发里程', width:60, align:'center'}
	           	 ,{field:'endNum', title: '归队里程', width:60, align:'center'}
	           	 ,{field:'useNum', title: '使用里程', width:70, align:'center',sortable:true}
	           	 //,{field:'otherFee', title: '过 / 停费', width:70, align:'center',sortable:true}
	           	 ,{field:'allFee', title: '总费用', width:60, align:'center',sortable:true}
	           	 ,{field:'dataSource', title: '来源', width:60, align:'center',sortable:true}
	           	 ,{field:'addTime', title: '创建时间', width:110, align:'center',sortable:true}
	           	 
	           ]],
	      loadFilter: function(data) {
	        	   if(data.result && data.result == 'fail') {	//失败时，错误消息提示
	        		   showWarnMsg(data.msg);
	        		   return {};
	        	   }else {
	        		   return data;
	        	   }
	           }           
	};
	

var datagrid = $("#dg"); //数据表格

$(function() {
	datagrid.datagrid(dgOptions); //绘制数据表格
	autoAddClear(); //为各组件自动填加‘清除’功能（组件需要增加 addClear属性 ）
});

//查询
function zcurdSearch() {
	var param = zcurdGetParam();
	datagrid.datagrid("load", param)
}

//获取查询参数
function zcurdGetParam() {
	var param = {};
	$("#tb :input[name]").each(function(i, item) {
		if($(item).val()) {
			param[$(item).attr("name")] = $(item).val();	
		}
	});
	//console.log(param);
	return param;
}

var initPara = zcurdGetParam(); //初始化参数，主要目的是保存一些隐藏条件

//详情
function detail() {
	var rowsSel = datagrid.datagrid("getChecked");
	if(rowsSel.length != 1) {
		showWarnMsg("请选择需要查看的一条数据");
		return;
	}
	var id = rowsSel[0].id;
	viewData(id)
}

//双击打开查看
function viewData(id){
	top.openWindow_view("详情", getCurrUrl("detailPage") + "?id=" + id, {size: '780x490'});
}


//扩展js
//格式化类型对象的输出
function formatType(value)
{
	if(value == null)
	{
		return "";
	}
	return value.name;
};

function formatState(value)
{
	if(value == null)
	{
		return "";
	}
	if(value.code=='04')
	{
		return "<span style='color:#ff0000'>"+value.name+"</span>";
	}
	return value.name;
};

function formatResultType(value)
{
	if(value.code=='01')
	{
		return value.name;
	}
	else
	{
		return "<span style='color:#ff0000'>"+value.name+"</span>";
	}
};

</script>

<#include "/base/common/dialogWindow.html"/>
<#include "/base/common/foot.html"/>
